{-# OPTIONS_HADDOCK prune, ignore-exports #-}
module TIParser
(
  parseExpr
)
where

import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Char

import TITypes  


parseExpr = try parseApp
        <|> parseExpr'


parseExpr' = parseAbs
         <|> parseVar
         <|> between (char '(') (char ')') parseExpr


parseVar = do name <- letter
              return $ Var [name]


parseApp = parseExpr' `chainl1` (return App)


parseAbs = do char '\\'
              name <- letter
              char '.'
              expr <- parseExpr
              return $ Abs [name] expr

